/*
 * @Author: guandeshen 295570679@qq.com
 * @Date: 2024-05-11 21:09:19
 * @LastEditors: 关德参 2257609862@qq.com
 * @LastEditTime: 2024-09-19 15:04:37
 * @FilePath: /task-admin/src/views/task/config/content.ts
 * @Description:
 *
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
 */
import TaskAPI from "@/api/task";
import type { TaskQuery } from "@/api/task/model";
import type { IContentConfig } from "@/components/PageContent/index.vue";
import i18n from "@/lang/index";

const contentConfig: IContentConfig<TaskQuery> = {
  searchPlaceholder: i18n.global.t("common.searchPlaceholder"),
  hasDashData: false,
  pageName: "taskList",
  tableName: "Task List",
  table: {
    highlightCurrentRow: true,
  },
  indexAction: function (params) {
    if ("createAt" in params) {
      const createAt = params.createAt as number[];
      params.project_id = createAt[0];
      params.site_id = createAt[1];
      delete params.createAt;
    }
    return TaskAPI.getPage(params);
  },
  deleteAction: TaskAPI.deleteByIds,
  pk: "id",
  toolbar: [
    "refresh",
    "add",
    "delete",
    // "export",
    // {
    //   name: "import",
    //   icon: "upload",
    //   text: i18n.global.t("common.import"),
    //   auth: "import",
    // },
  ],
  cols: [
    // { type: "selection", width: 50, align: "center" },
    {
      label: i18n.global.t("common.taskName"),
      align: "left",
      tooltip: true,
      minWidth: 140,
      prop: "task_name",
    },
    {
      label: i18n.global.t("common.startDate"),
      prop: "start_d",
      align: "left",
      tooltip: true,
      minWidth: 120,
      // width: 120,
    },
    {
      label: i18n.global.t("common.endDate"),
      align: "left",
      tooltip: true,
      minWidth: 120,
      prop: "end_d",
    },
    {
      label: i18n.global.t("common.projectName"),
      align: "left",
      tooltip: true,
      minWidth: 140,
      prop: "project_name",
    },
    {
      label: i18n.global.t("common.WBS"),
      align: "left",
      tooltip: true,
      minWidth: 140,
      prop: "wbs_name",
    },
    {
      label: i18n.global.t("common.status"),
      align: "left",
      prop: "status",
      slotName: "status",
      templet: "custom",
      width: 150,
    },
    {
      label: i18n.global.t("common.operation"),
      fixed: "right",
      width: 240,
      templet: "tool",
      operat: ["view", "edit", "delete"], //"edit",
    },
  ],
};

export default contentConfig;
